// KeyControl.cpp: implementation of the CKeyControl class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "KeyControl.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CKeyControl::CKeyControl()
{
	ClearBuffer();
}

CKeyControl::~CKeyControl()
{

}

void CKeyControl::ClearBuffer()
{
	memset(KeyState, 0, sizeof(KeyState));
}

BOOL CKeyControl::CheckKeyDown(int keynum)
{
	//if(HIBYTE(GetAsyncKeyState(keynum))) return TRUE;
	SHORT temp = GetAsyncKeyState(keynum);

	if((SHORT)0x8000 & GetAsyncKeyState(keynum)) 
	{
		return TRUE;
	}
	return FALSE;
}

void CKeyControl::OnKeyDown(UINT nChar)
{
	KeyState[nChar] = 1;
}

void CKeyControl::OnKeyUp(UINT nChar)
{
	KeyState[nChar] = 0;
}